home *** CD-ROM | disk | FTP | other *** search
/ Personal Paint v7.1 / Cloanto Personal Paint v7.1.iso / utilities / developer_docs / personal_io / include / libraries / personal_io.h
C/C++ Source or Header  |  1996-10-27  |  11KB  |  353 lines

  1. #ifndef LIBRARIES_PERSONAL_IO_H
  2. #define LIBRARIES_PERSONAL_IO_H TRUE
  3. /*
  4. **  $VER: personal_io.h 5.0 (22.5.96)
  5. **  Includes Release 5.0
  6. **
  7. **  Interface definitions for PersonalIO applications.
  8. **
  9. **  Copyright ⌐ 1995, 1996 Cloanto Italia srl
  10. **        All Rights Reserved
  11. */
  12. #ifndef EXEC_TYPES_H
  13. #include <exec/types.h>
  14. #endif /* EXEC_TYPES_H */
  15.  
  16. #ifndef    GRAPHICS_GFX_H
  17. #include <graphics/gfx.h>
  18. #endif /* GRAPHICS_GFX_H */
  19.  
  20. #define IOLIB_VERSION    5    /* current interface version */
  21.  
  22.  
  23. /*
  24.  *  Picture type description structure
  25.  */
  26. struct DataInfo
  27. {
  28.     WORD Version;        /* client program interface version */
  29.     ULONG Code;        /* picture type code */
  30.     ULONG Flags;        /* attributes */
  31.     ULONG ProcessData;    /* data items processable */
  32.     LONG  Priority;        /* sort priority */
  33.     UBYTE Name[40];        /* full name */
  34.     UBYTE ShortName[16];    /* short name */
  35.     UBYTE FileSuffix[3][16];/* file name suffixes ('.' included) */
  36.     UBYTE *HandshakeText;    /* handshaking string */
  37.     UBYTE pad[28];
  38. };
  39.  
  40. /* DataInfo Code */
  41. #define DIC_ANYDATA  0xFFFFFFFF    /* Load operations (PictureInfo.Data.Code):
  42.                  * the client program is asking
  43.                  * for any picture type to be loaded. */
  44.  
  45. /* DataInfo Flags */
  46. #define DIF_LOAD    0x00000001  /* planar images can be loaded */
  47. #define DIF_LOAD_24    0x00000002  /* 24bit chunky images can be loaded */
  48. #define DIF_SAVE    0x00000004  /* planar images can be saved */
  49. #define DIF_SAVE_24    0x00000008  /* 24bit chunky images can be saved */
  50. #define DIF_LOADFILE    0x00000010  /* the data are read from file */
  51. #define DIF_SAVEFILE    0x00000020  /* the data are written to file */
  52. #define DIF_RECOGNIZE    0x00000040  /* image files can be recognized */
  53. #define DIF_ENCRYPTED    0x00000080  /* the data are encrypted */
  54. #define DIF_CUSTOMIO    0x00000100  /* custom file I/O */
  55. #define DIF_LOADOPTS    0x00000200  /* options for ReadPicture() */
  56. #define DIF_SAVEOPTS    0x00000400  /* options for WritePicture() */
  57. #define DIF_SELFLOPT    0x00000800  /* custom load-options handling */
  58. #define DIF_SELFSOPT    0x00001000  /* custom save-options handling */
  59. #define DIF_CONVERTED    0x00002000  /* the data come from a foreign library */
  60.  
  61. /* DataInfo ProcessData */
  62. #define PCDT_FORMAT    0x00000001  /* Width, Height, Depth */
  63. #define PCDT_IMAGE    0x00000002  /* BitMap */
  64. #define PCDT_MASK    0x00000004  /* MaskPlane */
  65. #define PCDT_PALETTE    0x00000008  /* Palette */
  66. #define PCDT_PRJINFO    0x00000010  /* ProjInfo */
  67. #define PCDT_DPI    0x00000020  /* HorizDPI, VertDPI */
  68. #define PCDT_DISPID    0x00000040  /* DisplayID */
  69. #define PCDT_HANDLE    0x00000080  /* HandleX, HandleY */
  70. #define PCDT_EDGES    0x00000100  /* LeftEdge, TopEdge */
  71. #define PCDT_SRCDIM    0x00000200  /* SourceWidth, SourceHeight */
  72. #define PCDT_TRANSPT    0x00000400  /* TranspType */
  73. #define PCDT_TRANSPC    0x00000800  /* TransparentColor */
  74.  
  75.  
  76. /*
  77.  *   Picture data/resource structure
  78.  */
  79. struct PictureInfo
  80. {
  81.     /*
  82.      *  Section 1: I/O information
  83.      */
  84.     WORD Version;            /* client program interface version */
  85.     UBYTE *FileName;        /* file being read/written */
  86.     UBYTE FileHead[128];        /* first bytes from file */
  87.     struct DataInfo Data;        /* picture type selected */
  88.     ULONG ProcessData;        /* data to read/write */
  89.     ULONG ProcessedData;        /* data read/written */
  90.     ULONG Flags;            /* unused */
  91.     APTR  Parameters;        /* unused */
  92.     APTR  User1, User2, User3;    /* user extensions */
  93.  
  94.     /*
  95.      *  Section 2: picture information
  96.      */
  97.     WORD Width, Height;        /* image width and height */
  98.     UBYTE Depth;            /* image depth (bits per pixels) */
  99.     UBYTE pad1;
  100.     WORD HandleX, HandleY;        /* handle (hot spot) */
  101.     WORD HorizDPI, VertDPI;        /* ratio (dots per inch) */
  102.     WORD LeftEdge, TopEdge;        /* source coordinates */
  103.     WORD SourceWidth, SourceHeight;    /* source format */
  104.     UBYTE TranspType;        /* transparency type */
  105.     UBYTE TransparentColor;        /* transparent color */
  106.     ULONG DisplayID;        /* screen display mode */
  107.     ULONG pad2[10];
  108.  
  109.     /*
  110.      *  Section 3: picture resources
  111.      */
  112.     struct BitMap *BMap;        /* image bitmap */
  113.     PLANEPTR MaskPlane;        /* stencil/alpha plane */
  114.     struct Color *Palette;        /* color palette */
  115.     struct ProjectInfo *ProjInfo;    /* project information */
  116.     ULONG pad3[10];
  117.  
  118.     /*
  119.      *  Section 4: preview information
  120.      */
  121.     UBYTE PreviewDepth;        /* preview screen depth */
  122.     UBYTE pad4;
  123.     struct Color *PreviewPalette;    /* preview screen colors (HAM) */
  124.     ULONG PreviewDisplayID;        /* preview screen mode (HAM) */
  125.     ULONG pad5[10];
  126.  
  127.     /*
  128.      *  Section 5: client program information
  129.      */
  130.     LONG  UILanguage;        /* active language */
  131.     UBYTE **LibUIText;        /* IO library strings */
  132.     ULONG pad6[10];
  133.  
  134.     /*
  135.      *  Section 6: library bases
  136.      */
  137.     struct ExecBase *SysBase;
  138.     struct DosLibrary *DOSBase;
  139.     struct GfxBase *GfxBase;
  140.     struct IntuitionBase *IntuitionBase;
  141.     struct Library *IconBase;
  142.     ULONG pad7[10];
  143.  
  144.     /*
  145.      *  Section 7: function pointers
  146.      */
  147.     BOOL  (*ReadFile) (UBYTE *buffer, LONG bytes);        // functions
  148.     BOOL  (*WriteFile) (UBYTE *buffer, LONG bytes);
  149.     LONG  (*SeekFile) (WORD mode, LONG bytes);
  150.     BOOL  (*BumpProgress) (void);
  151.     UBYTE (*FastReadPix) (struct BitMap *bmap, WORD x, WORD y);
  152.     void  (*FastWritePix) (struct BitMap *bmap, WORD x, WORD y, UBYTE col);
  153.     void  (*ChunkyToBMap) (UBYTE *pixbuf, struct BitMap *bmap, LONG offs);
  154.     void  (*CommentToProjInfo) (UBYTE *buffer, struct ProjectInfo *pinfo);
  155.     BOOL  (*ProjInfoToComment) (struct ProjectInfo *pinfo, UBYTE *buffer, WORD maxsize, BOOL do_auth, BOOL do_cpyr, BOOL do_note);
  156.     UBYTE (*CryptKeyChar) (BOOL reset);
  157.     WORD  (*CryptKeySign) (void);
  158.     void  (*PreviewRow) (struct BitMap *bmap, WORD y);
  159.     struct BitMap *(*CreateBitMap)(WORD width, WORD height, UBYTE depth, UWORD flags);
  160.     void  (*DeleteBitMap)(struct BitMap *bmap);
  161.     /* V4 functions */
  162.     UBYTE *(*GetProjectInfo) (struct ProjectInfo *pinfo, WORD type);
  163.     BOOL  (*SetProjectInfo) (struct ProjectInfo *pinfo, WORD type, UBYTE *string);
  164.     BOOL  (*ProjectInfoToComment) (struct ProjectInfo *pinfo, UBYTE *buffer, WORD maxsize, ULONG do_flags);
  165. };
  166.  
  167.  
  168.  
  169.  
  170. /*
  171.  *   Option structure
  172.  */
  173. struct DataOption
  174. {
  175.     WORD  Version;        /* client program interface version */
  176.     WORD  Type;        /* option type */
  177.     UBYTE Name[40];        /* option name */
  178.     LONG  UITextStr;    /* client program user interface text */
  179.     ULONG Flags;        /* attributes */
  180.     LONG  Value;        /* current value */
  181.     LONG  Min, Max, Default;/* minimum, maximum and default values */
  182.     UBYTE String[80];    /* current string */
  183.     UBYTE pad[32];
  184. };
  185.  
  186. /* DataOption Type */
  187. #define DOT_INTSTR    0  /* integer value (string gadget) */
  188. #define DOT_INTSLIDE    1  /* integer value (proportional gadget) */
  189. #define DOT_10000STR    2  /* value in 1/10000s (string gadget) */
  190. #define DOT_BOOL    3  /* boolean value (checkbox gadget) */
  191. #define DOT_STRING    4  /* string (string gadget) */
  192. #define DOT_COLSLIDE    5  /* depth value (proportional gadget) */
  193.  
  194. /* DataOption UITextStr */
  195. #define DOUI_WIDTH    0  /* Width: */
  196. #define DOUI_HEIGHT    1  /* Height: */
  197. #define DOUI_DEPTH    2  /* Depth: */
  198. #define DOUI_COLUMNS    3  /* Columns: */
  199. #define DOUI_ROWS    4  /* Rows: */
  200. #define DOUI_COMPR    5  /* Compression: */
  201. #define DOUI_MAXCOMP    6  /* Max Compression: */
  202. #define DOUI_QUALITY    7  /* Quality: */
  203. #define DOUI_SMOOTH    8  /* Smooth: */
  204. #define DOUI_SCRFMT    9  /* Screen Format: */
  205. #define DOUI_PROGDSP    10 /* Progressive Display: */
  206. #define DOUI_AUTO    11 /* Automatic: */
  207. #define DOUI_PADBYTE    12 /* Pad Byte: */
  208. #define DOUI_BINARY    13 /* Binary: */
  209. #define DOUI_FORMAT    14 /* Format: */
  210. #define DOUI_COLORS    15 /* Colors: */
  211. #define DOUI_GRAINNS    16 /* Graininess: */
  212. #define DOUI_RSEED     17 /* Random Seed: */
  213. #define DOUI_GRAYS    18 /* Gray shades: */
  214. #define DOUI_CMPTIB    19 /* Compatibility: */
  215. #define DOUI_PARAM1    20 /* Parameter 1: */
  216. #define DOUI_PARAM2    21 /* Parameter 2: */
  217. #define DOUI_PARAM3    22 /* Parameter 3: */
  218. #define DOUI_NONE    -1
  219.  
  220. /* DataOption Flags */
  221. #define DOF_LOADOPTION    0x00000001  /* ReadPicture() option */
  222.  
  223.  
  224.  
  225.  
  226. /*
  227.  *   Color palette structure
  228.  */
  229. struct Color
  230. {
  231.     UBYTE Red, Green, Blue;    /* color components */
  232.     UBYTE EFlag;        /* unused */
  233. };
  234.  
  235.  
  236.  
  237.  
  238. /*
  239.  *   Project information structure
  240.  *
  241.  *   Note: This information must be accessed directly up to version 3 of
  242.  *   the client I/O interface, and must instead be accessed via the
  243.  *   GetProjectInfo() and SetProjectInfo() functions starting from clients
  244.  *   having version 4 or higher.
  245.  */
  246. #define PRJINF_AUTSIZE   80
  247. #define PRJINF_COPYRSIZE 80
  248. #define PRJINF_ANNOTSIZE 80
  249.  
  250. struct ProjectInfo
  251. {
  252.     UWORD FromFile;   /* private: do not change */
  253.     UBYTE Author[PRJINF_AUTSIZE];
  254.     UBYTE Copyright[PRJINF_COPYRSIZE];
  255.     UBYTE Annotation[PRJINF_ANNOTSIZE];
  256.     /* V4: Data beyond this point! */
  257. };
  258.  
  259.  
  260.  
  261.  
  262. /* SetProjectInfo() type */
  263. #define AUTHOR_INFO    0
  264. #define COPYRIGHT_INFO    1
  265. #define ANNOTATION_INFO    2
  266.  
  267. /* ProjectInfoToComment() do_flags */
  268. #define AUTHOR_INFOF        (1<<0)
  269. #define COPYRIGHT_INFOF        (1<<1)
  270. #define ANNOTATION_INFOF    (1<<2)
  271.  
  272. /* SeekFile() mode */
  273. #define SKF_ABSOLUTE        0    // seek from position 0
  274. #define SKF_FROMCURR        1    // seek from current position
  275.  
  276. /* FastReadPix() FastWritePix() x */
  277. #define FBMP_INIT    -1    /* initialize bitmap reading/writing */
  278. #define FBMP_FLUSH    -2    /* flushes row buffer (FastWritePix()) */
  279.  
  280. /* CreateBitMap() flags */
  281. #define CB_CLEAR    0x0001    /* clear all bitmap memory */
  282. #define CB_CLEAN    0x0002    /* clear unused (rightmost) bitmap memory */
  283. #define CB_KEEPWB    0x0004    /* do not use virtual memory */
  284. #define CB_ANYMEM    0x0008    /* use any memory */
  285. #define CB_FASTMEM    0x0010    /* use fast memory only */
  286. #define CB_LONGW    0x0020    /* BytesPerRow forced to a multiple of 4 */
  287. #define CB_CHIPMEM    0x0040    /* use chip memory only */
  288.  
  289. /*
  290.  * SetOption(dinfo, SOPT_SELFLOPT) activates
  291.  * the library load-option interface (DIF_SELFLOPT picture types only)
  292.  */
  293. #define SOPT_SELFLOPT    ((struct DataOption *)0L)
  294.  
  295. /*
  296.  * SetOption(dinfo, SOPT_SELFSOPT) activates
  297.  * the library save-option interface (DIF_SELFSOPT picture types only)
  298.  */
  299. #define SOPT_SELFSOPT    ((struct DataOption *)0xFFFFFFFF)
  300.  
  301.  
  302.  
  303.  
  304. /*
  305.  *  GetPictureInfo(), ReadPicture(), WritePicture() return codes
  306.  */
  307. #define PIOERR_OK    0  /* no error / file recognized */
  308. #define PIOERR_CANCEL    1  /* user cancelled */
  309. #define PIOERR_PARTIAL    2  /* image data partially loaded */
  310. #define PIOERR_BADVER    3  /* a newer interface version is required */
  311. #define PIOERR_BADTYPE    4  /* file not recognized */
  312. #define PIOERR_FILE_ERR    5  /* file I/O error */
  313. #define PIOERR_NODATA    6  /* the file does not contain the required data */
  314. #define PIOERR_NOMEMORY    7  /* not enough memory */
  315. #define PIOERR_NODECRYP    8  /* decryption impossible */
  316. #define PIOERR_UIMGTYP    9  /* unsupported image type */
  317. #define PIOERR_UKCMPR    10 /* uncknown compression */
  318. #define PIOERR_BADDATA    11 /* error in file data */
  319.  
  320.  
  321.  
  322.  
  323. /*
  324.  *  Picture type and option storage structures
  325.  *
  326.  *  Note: these are not part of the library interface, but instead
  327.  *        are just a storage system for library implementations.
  328.  */
  329. struct DataInfoEntry
  330. {
  331.     ULONG Code;        /* picture type code */
  332.     ULONG Flags;        /* attributes */
  333.     ULONG ProcessData;    /* data items processable */
  334.     LONG  Priority;        /* sort priority */
  335.     UBYTE *Name;        /* full name */
  336.     UBYTE *ShortName;    /* short name */
  337.     UBYTE *FileSuffix[3];    /* file name suffixes ('.' included) */
  338. };
  339.  
  340. struct DataOptionEntry
  341. {
  342.     WORD  Type;        /* option type */
  343.     UBYTE *Name;        /* option name */
  344.     LONG  UITextStr;    /* client program user interface text */
  345.     ULONG Flags;        /* attributes */
  346.     LONG  Value;        /* current value */
  347.     LONG  Min, Max, Default;/* minimum, maximum and default values */
  348.     UBYTE String[80];    /* current string */
  349. };
  350.  
  351.  
  352. #endif /* LIBRARIES_PERSONAL_IO_H */
  353.